import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteEslint from 'vite-plugin-eslint';
import path from 'path';

export default defineConfig({
  plugins: [
    react(),
    viteEslint({
      // 开发过程不会因为警告/报错中止程序
      failOnError: false
    })
  ],
  server: {
    port: 3000, // 服务启动端口，若被占用会自动寻找下一可用端口
    open: true, // 是否自动打开浏览器
    host: '0.0.0.0' // 解决启动后Network: use --host to expose问题
  },
  // 添加环境变量指向文件
  envDir: path.resolve(__dirname, './env'),
  // 别名
  resolve: {
    alias: {
      '@': path.resolve('./src'),
      '@assets': path.resolve('./src/assets'),
      '@components': path.resolve('./src/components'),
      '@customTypes': path.resolve('./src/customTypes'),
      '@enumTypes': path.resolve('./src/enumTypes'),
      '@layouts': path.resolve('./src/layouts'),
      '@pages': path.resolve('./src/pages'),
      '@rootPages': path.resolve('./src/rootPages'),
      '@routes': path.resolve('./src/routes'),
      '@services': path.resolve('./src/services'),
      '@stores': path.resolve('./src/stores'),
      '@utils': path.resolve('./src/utils')
    }
  }
});
